﻿
using System.Collections.Generic;
using UnityEngine;
namespace BridgeShips {
    public class SpitReceivedMsgs {
        static List<string> msgList = new List<string>();
        private static string[] Str;
        private static string[] ArrStr;
        public static List<string> SpitMsgs( string date ) {

            msgList.Clear();
            Str = date.Split( ':' );
            msgList.Add( Str[0] );

            ArrStr = Str[1].Split( ',' );
            if (Str[0] == "NineID") {
                for (int i = 0; i < ArrStr.Length; i++) {
                    msgList.Add( ArrStr[i].Split( '_' )[0] );
                    msgList.Add( ArrStr[i].Split( '_' )[1] );
                }
                return msgList;
            }
            for (int i = 0; i < ArrStr.Length; i++) {
                msgList.Add( ArrStr[i] );
            }
            return msgList;
        }
        /// <summary>
        /// 获取数据头的信息
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetHeadString(string date) {
            return date.Split(':')[0];
        }
        /// <summary>
        /// 获取ID消息头
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetIDHead(string date) {
            return date.Split(',')[0];
        }
    }
}